package cn.itcast.demo;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class TestExample {
    public static void main(String[] args) {
        Example example = new Example();
      Example example1  =(Example) Enhancer.create(example.getClass(), new MethodInterceptor() {
            @Override
            public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
                System.out.println("AAAAAAAAAAAAAA");
                method.invoke(example,objects);
              //AAAAAAAAAAAAAA
                //123
                return null;
            }
        });
      example1.display();
    }
}
